package com.mc.designpattern.strategy;

import com.mc.designpattern.strategy.service.IOrderChannelService;
import com.mc.designpattern.strategy.util.Channel;
import com.mc.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping()
public class OrderChannelController {
    @Autowired
    IOrderChannelService channelService;

    @GetMapping("/handler/{type}")
    @ResponseBody
    public Result handleOrder(@PathVariable Integer type) {
        Channel c = Channel.build()
                .add("name", "奥克斯订单")
                .add("price", 99.9)
                .add("type", type);
        channelService.handleChannel(c);
        return Result.success(type);
    }

    @GetMapping("/handler2/{type}")
    @ResponseBody
    public Result handleOrder2(@PathVariable Integer type) {
        Channel c = Channel.build()
                .add("name", "奥克斯订单")
                .add("price", 99.9)
                .add("type", type);
        channelService.handleChannel(c);
        return Result.success(type);
    }
}
